/*  WifiNetwork.java - Details about a single wifi network 
 
        Copyright (C) 2009 Devendra Laulkar

        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation version 2 of the License. 

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package com.intellBatt;

public class WifiNetwork {

	
	private String bssid;
	private int lastSignalVal,maxValue, minValue;
	private double averageVal;
	private int numVals;
	private int connected;
	
	
	public String getBssid() {
		return bssid;
	}
	public void setBssid(String bssid) {
		this.bssid = bssid;
	}
	public int getLastSignalVal() {
		return lastSignalVal;
	}
	public void setLastSignalVal(int lastSignalVal) {
		this.lastSignalVal = lastSignalVal;
	}
	public double getAverageVal() {
		return averageVal;
	}
	public void setAverageVal(double averageVal) {
		this.averageVal = averageVal;
	}
	
	
	public WifiNetwork(String bssid)
	{
		this(bssid, 0.0, 0, -100);
	}

	public WifiNetwork(String bssid, double avg, int max, int min)
	{
		setBssid(bssid);
		setLastSignalVal(0);
		setAverageVal(avg);
		numVals = 0;
		
		
		setMinValue(max);
		setMaxValue(min);	
	}
//	public WifiNetwork(String bssid, double signal)
//	{
//		
//	}
	
	public int getMaxValue() {
		return maxValue;
	}
	public void setMaxValue(int maxValue) {
		this.maxValue = maxValue;
	}
	public double getMinValue() {
		return minValue;
	}
	public void setMinValue(int minValue) {
		this.minValue = minValue;
	}
	public void addSignal(int signalStrength)
	{
		setLastSignalVal(signalStrength);
		setAverageVal(((numVals * getAverageVal())  + signalStrength )/ (numVals + 1) );
		numVals = numVals + 1;
		if(signalStrength <= getMinValue())
		{
			setMinValue(signalStrength);
		}

		if(signalStrength >= getMaxValue())
		{
			setMaxValue(signalStrength);
		}
	}
	public void setConnected(int connected) {
		this.connected = connected;
	}
	public int getConnected() {
		return connected;
	}
}
